package com.education.platform.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;

/**
 * 推送订阅表
 *
 * @author education-platform
 * @since 2024-10-07
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("push_subscribe")
@JsonIgnoreProperties(value = {"handler"})
public class PushSubscribe {

    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 用户ID
     */
    @TableField("user_id")
    private Long userId;

    /**
     * 客户端类型
     */
    @TableField("client_type")
    private String clientType;

    /**
     * 推送令牌
     */
    @TableField("client_token")
    private String clientToken;

    /**
     * 设备信息
     */
    @TableField("device_info")
    private String deviceInfo;

    /**
     * 是否激活
     */
    @TableField("is_active")
    private Boolean isActive;

    /**
     * 最后活跃时间
     */
    @TableField("last_active_at")
    private LocalDateTime lastActiveAt;

    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;

    // 关联对象（用于XML映射）
    @TableField(exist = false)
    private User user;

    // 枚举定义
    public enum ClientType {
        WEB("网页端"),
        ANDROID("安卓端"),
        IOS("苹果端"),
        WECHAT("微信小程序");

        private final String description;

        ClientType(String description) {
            this.description = description;
        }

        public String getDescription() {
            return description;
        }
    }
}
